const Magazine = require('../models/magazine');

const { Op } = require('sequelize');

//添加文章
exports.addMagazine = async function(params) {}
    //查询文章
exports.findMagazine = async function(category, pagenum = 1, pagesize = -1) {
    const total = await Magazine.count();
    limit = pagesize == -1 ? total : pagesize;
    const lists = await Magazine.findAll({
        where: {
            category: {
                [Op.like]: category ? category : '%'
            }
        },
        offset: (pagenum - 1) * limit,
        limit: +limit
    })
    return { lists, total }
}